﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using System;
using System.Diagnostics;
using System.Reflection;
using Fulcrum.DispatcherProxies;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Fulcrum.UnitTests.DispatcherProxies
{
    [TestClass]
    public class DispatcherProxyEventInfoTests
    {
        public DispatcherProxyEventInfoTests()
        {
            // nothing
        }

        EventInfo eventInfo;
        DispatcherProxyEventInfo proxyEventInfo;

        public event EventHandler MyEvent;

        //
        // This is here to supress a compiler warning
        //
        void RaiseEvent()
        {
            MyEvent(this, EventArgs.Empty);
        }

        [TestInitialize]
        public void TestInitialize()
        {
            this.eventInfo = GetEventInfo();
            this.proxyEventInfo = new DispatcherProxyEventInfo(this.eventInfo);
        }

        EventInfo GetEventInfo()
        {
            var type = this.GetType();
            var @event = type.GetEvent("MyEvent");

            Debug.Assert(@event != null);

            return @event;
        }

        [TestMethod]
        public void TestDispatcherProxyEventInfoName()
        {
            Assert.AreEqual("MyEvent",this.proxyEventInfo.Name);
        }

        [TestMethod]
        public void TestDispatcherProxyEventInfoHandlerType()
        {
            Assert.AreEqual(typeof(EventHandler), this.proxyEventInfo.HandlerType);
        }


    }
}
